﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using ServiciosTuristicosIntegrales.EntityClasses;
using NHibernate;

namespace ServiciosTuristicosIntegrales.WebServices
{
    /// <summary>
    /// Summary description for HotelWS
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class HotelWS : System.Web.Services.WebService
    {

        [WebMethod]
        public string GuardarHotel(Hotel hotel)
        {
            ISession session;
            try
            {
                session = SessionManager.OpenSession();
                try
                {
                    session.Save( hotel);
                    session.Flush();
                }
                catch (Exception ex)
                {
                    return ex.Message;
                }
                finally
                {
                    session.Close();
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return "Se  ha registrado satisfactoriamente";
        } 
    }
}
